//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web.UI.WebControls;
using CommunityServer.Components;
using CommunityServer.ControlPanel.Controls;
using CommunityServer.ControlPanel.UI;
using CommunityServer.Controls;

namespace CommunityServer.ControlPanel.Tools
{
	/// <summary>
	/// Summary description for EventEntryDetails.
	/// </summary>
	public class EventEntryDetails : BaseToolsPage
	{
		protected Label EntryID;
		protected Label EventMessage;
		protected Label Category;
		protected Label EventDate;
		protected Label MachineName;
		protected Label EventID;
		protected Label EventType;
		protected Label SettingsID;

		private EventLogEntry entry = null;

		override protected void OnInit(EventArgs e)
		{
			this.Load += new EventHandler(this.Page_Load);
			base.OnInit(e);
		}

		private void Page_Load(object sender, EventArgs e)
		{
			CSContext context = CSContext.Current;
			int entryID = context.GetIntFromQueryString("EntryID", 0);

			Head.AddTitle("Event Log Entry", this.Context);

			entry = CommonDataProvider.Instance().GetEventLogEntry(entryID);
			Bind();
		}

		private void Bind()
		{
			EntryID.Text = entry.EntryID.ToString();
			EventMessage.Text = entry.Message.Replace("\n","<br />");
			Category.Text = entry.Category;
			EventDate.Text = entry.EventDate.ToString(CSContext.Current.User.Profile.DateFormat);
			MachineName.Text = entry.MachineName;
			EventID.Text = entry.EventID.ToString();
			EventType.Text = entry.EventType.ToString();
			SettingsID.Text = entry.SettingsID.ToString();
		}
	}
}
